package main

import (
	"Goproject/middleware"
	"Goproject/models"

	"Goproject/controller"
	"Goproject/dao"
	"github.com/gin-gonic/gin"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

func main() {
	err := dao.InitMysql()
	if err != nil {
		panic(err)
	}
	ec := dao.InitRedis()
	if ec != nil {
		panic(ec)
	}
	defer dao.DB.Close()
	defer dao.Redis.Close()
	dao.DB.AutoMigrate(models.UserInfo{})
	r := gin.Default()
	r.Use(middleware.Cors())
	r.GET("/login", controller.Login)
	r.GET("/rlogin", controller.Rmlogin)
	r.POST("/register", controller.Register)
	r.Run(":5000")
}
